package com.zggao.controller;

import com.zggao.controller.frontend.MainPageController;
import com.zggao.controller.superadmin.HeadLineOperationController;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//1.拦截所有的请求，通过/
@WebServlet("/")
public class DispatchServlet extends HttpServlet {

    //2.解析请求
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        if(req.getServletPath()=="/frontend/getmainpageinfo" && req.getMethod()=="GET"){
            new MainPageController().getMainPageInfo(req,resp);
        }else if(req.getServletPath()=="/frontend/addheadline" && req.getMethod()=="GET"){
            new HeadLineOperationController().addHeadLine(req,resp);
        }
    }
}
